/*
 *  Copyright 2005 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.model.core.statistics;

import com.blandware.atleap.model.core.BaseObject;

import java.util.Date;

/**
 * <p>Represents a search case which occured when user searched something
 * using embedded search system.</p>
 * <p><a href="SearchCase.java.html"><i>View source</i></a></p>
 *
 * @author Roman Puchkovskiy <a href="mailto:roman.puchkovskiy@blandware.com">
 *         &lt;roman.puchkovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.2 $ $Date: 2006/06/15 10:52:36 $
 * @hibernate.class table="`al_core_search_case`" lazy="false"
 */
public class SearchCase extends BaseObject {
    /**
     * ID
     */
    protected Long id;
    /**
     * Query itself
     */
    protected String query;
    /**
     * Date when search occured
     */
    protected Date date;

    /**
     * Constructs a SearchCase instance.
     */
    public SearchCase() {
    }

    /**
     * Returns ID.
     *
     * @return ID
     * @hibernate.id column="`id`"
	 * generator-class="increment" unsaved-value="null"
     */
    public Long getId() {
        return id;
    }

    /**
     * Sets ID.
     *
     * @param id ID to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * Returns a query.
     *
     * @return query
     * @hibernate.property
	 * @hibernate.column name="`query`" not-null="true" unique="false"
     * length="252"
     */
    public String getQuery() {
        return query;
    }

    /**
     * Sets a query.
     *
     * @param query query to set
     */
    public void setQuery(String query) {
        this.query = query;
    }

    /**
     * Returns date.
     *
     * @return date
     * @hibernate.property type="timestamp"
	 * @hibernate.column name="`date`"  not-null="true"
     * unique="false"
     */
    public Date getDate() {
        return date;
    }

    /**
     * Sets date.
     *
     * @param date date to set
     */
    public void setDate(Date date) {
        this.date = date;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof SearchCase)) {
            return false;
        }

        final SearchCase searchCase = (SearchCase) o;

        if (date != null ? !date.equals(searchCase.date) : searchCase.date != null) {
            return false;
        }
        if (query != null
                ? !query.equals(searchCase.query) : searchCase.query != null) {
            return false;
        }

        return true;
    }

    public int hashCode() {
        int result;
        result = (query != null ? query.hashCode() : 0);
        result = 29 * result + (date != null ? date.hashCode() : 0);
        return result;
    }
}
